package com.eks.nacos.order.controller;

import com.eks.nacos.order.feign.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * OrderController
 *
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2021-01-21 14:37
 */
@RefreshScope
@RestController
public class OrderController {

    @Value("${u.name}")
    private String userName;

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    UserFeign userFeign;

    @GetMapping("/getUserName1")
    public String getUserName1(){
        return restTemplate.getForEntity("http://service-user/getUserName", String.class).getBody();
    }

    @GetMapping("/getUserName2")
    public String getUserName2(){
        return userFeign.getUserName();
    }

    @GetMapping("/getUserName3")
    public String test(){
        return "OrderController test: " + userName;
    }
}
